<%--<%@ page import="com.shop.model.Course" %>--%>
<%--<%@ page import="java.util.List" %>&lt;%&ndash;--%>
<%--  Created by IntelliJ IDEA.--%>
<%--  User: Administrator--%>
<%--  Date: 2025/5/25--%>
<%--  Time: 上午10:46--%>
<%--  To change this template use File | Settings | File Templates.--%>
<%--&ndash;%&gt;--%>
<%--<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>--%>
<%--<!DOCTYPE html>--%>
<%--<html>--%>
<%--<head>--%>
<%--    <meta charset="UTF-8">--%>
<%--    <title>订单确认</title>--%>
<%--    <style>--%>
<%--        .discount-price {--%>
<%--            color: red;--%>
<%--            font-size: 1.2em;--%>
<%--            font-weight: bold;--%>
<%--        }--%>
<%--    </style>--%>
<%--</head>--%>
<%--<body>--%>
<%--<h2>订单确认</h2>--%>
<%--<%--%>
<%--    List<Course> courses = (List<Course>) request.getAttribute("course");--%>

<%--    System.out.println("order.jsp:28:" + courses.size());--%>

<%--    String studentId = (String) request.getAttribute("studentId");--%>
<%--    Double buy_tprice = (Double) request.getAttribute("buy_tprice");--%>
<%--    List<Double> buy_price = (List<Double>) request.getAttribute("buy_price");--%>

<%--    System.out.println("order.jsp:33:" + buy_price.size());--%>
<%--    --%>
<%--    if(!courses.isEmpty() && buy_price != null && courses.size() == buy_price.size()){--%>
<%--        for (int i = 0; i < courses.size(); i++) {--%>
<%--            Course course = courses.get(i);--%>
<%--            Double price = buy_price.get(i);--%>
<%--            System.out.println("order.jsp:33:" + course.getCourseName() + " " + price);//调试--%>
<%--%>--%>

<%--<h2>课程ID:<%= course.getCourseId() %></h2>--%>
<%--<p>课程名称:<%= course.getCourseName() %></p>--%>
<%--<p>教课老师:<%= course.getTeacher() %></p>--%>
<%--<p>所属类型:<%= course.getType() %></p>--%>
<%--<p>课时:<%= course.getTime() %></p>--%>
<%--<p>开课时间:<%= course.getStartDate() %></p>--%>
<%--<p>结课时间:<%= course.getEndDate() %></p>--%>
<%--<p>原价:<%= course.getPrice() %></p>--%>
<%--<p style="color: red">优惠价格:<%= price %></p>--%>
<%--<% }--%>
<%--}--%>
<%--%>--%>
<%--<h3 style="color: red">总价:<%=buy_tprice%></h3>--%>

<%--<form action="confirm_payment" method="post">--%>
<%--    <% for(Course course : courses) { %>--%>
<%--    <input type="hidden" name="courseIds" value="<%= course.getCourseId() %>">--%>
<%--    <% } %>--%>
<%--    <input type="hidden" name="studentId" value="<%= studentId %>">--%>
<%--    <input type="hidden" name="totalPrice" value="<%= buy_tprice %>">--%>
<%--    <input type="submit" value="确认付款">--%>
<%--</form>--%>
<%--<% if(request.getAttribute("error") != null){ %>--%>
<%--    <p style="color: red"><%= request.getAttribute("error") %></p>--%>
<%--<% } %>--%>
<%--</body>--%>
<%--</html>--%>

<%@ page import="com.shop.model.Course" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>订单确认</title>
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3a0ca3;
            --accent-color: #4895ef;
            --success-color: #4cc9f0;
            --danger-color: #f72585;
            --discount-color: #ff6b6b;
            --border-radius: 12px;
            --box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #f5f7ff;
            color: #333;
            line-height: 1.6;
            padding: 20px;
        }

        .order-container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            border-radius: var(--border-radius);
            box-shadow: var(--box-shadow);
            overflow: hidden;
            padding: 30px;
        }

        .order-header {
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }

        .order-header h2 {
            color: var(--primary-color);
            font-size: 28px;
            margin-bottom: 10px;
        }

        .course-card {
            border: 1px solid #eee;
            border-radius: var(--border-radius);
            padding: 20px;
            margin-bottom: 20px;
            background: #f9faff;
        }

        .course-title {
            font-size: 20px;
            font-weight: 600;
            color: var(--primary-color);
            margin-bottom: 15px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .course-id {
            font-size: 14px;
            color: #666;
            font-weight: normal;
        }

        .course-details {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 15px;
            margin-bottom: 15px;
        }

        .detail-item {
            margin-bottom: 10px;
        }

        .detail-label {
            font-size: 14px;
            color: #666;
            margin-bottom: 5px;
        }

        .detail-value {
            font-weight: 500;
        }

        .price-section {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 15px;
            padding-top: 15px;
            border-top: 1px dashed #ddd;
        }

        .original-price {
            text-decoration: line-through;
            color: #999;
        }

        .discount-price {
            color: var(--discount-color);
            font-size: 20px;
            font-weight: 700;
        }

        .total-price {
            text-align: right;
            margin: 30px 0;
            padding: 20px;
            background: #f0f7ff;
            border-radius: var(--border-radius);
            font-size: 22px;
            font-weight: 700;
        }

        .total-price span {
            color: var(--primary-color);
        }

        .payment-form {
            text-align: center;
            margin-top: 30px;
        }

        .payment-btn {
            padding: 14px 40px;
            background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
            color: white;
            border: none;
            border-radius: var(--border-radius);
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: var(--transition);
            box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
        }

        .payment-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
        }

        .error-message {
            color: var(--danger-color);
            text-align: center;
            margin: 20px 0;
            padding: 12px;
            background: rgba(247, 37, 133, 0.1);
            border-radius: var(--border-radius);
        }

        @media (max-width: 768px) {
            .course-details {
                grid-template-columns: 1fr;
            }

            .order-container {
                padding: 20px;
            }
        }
    </style>
</head>
<body>
<div class="order-container">
    <div class="order-header">
        <h2>订单确认</h2>
    </div>

    <%
        List<Course> courses = (List<Course>) request.getAttribute("course");
        String studentId = (String) request.getAttribute("studentId");
        Double buy_tprice = (Double) request.getAttribute("buy_tprice");
        List<Double> buy_price = (List<Double>) request.getAttribute("buy_price");

        if(!courses.isEmpty() && buy_price != null && courses.size() == buy_price.size()){
            for (int i = 0; i < courses.size(); i++) {
                Course course = courses.get(i);
                Double price = buy_price.get(i);
    %>

    <div class="course-card">
        <div class="course-title">
            <%= course.getCourseName() %>
            <span class="course-id">课程ID: <%= course.getCourseId() %></span>
        </div>

        <div class="course-details">
            <div class="detail-item">
                <div class="detail-label">授课教师</div>
                <div class="detail-value"><%= course.getTeacher() %></div>
            </div>

            <div class="detail-item">
                <div class="detail-label">课程类型</div>
                <div class="detail-value"><%= course.getType() %></div>
            </div>

            <div class="detail-item">
                <div class="detail-label">课时</div>
                <div class="detail-value"><%= course.getTime() %></div>
            </div>

            <div class="detail-item">
                <div class="detail-label">开课时间</div>
                <div class="detail-value"><%= course.getStartDate() %></div>
            </div>

            <div class="detail-item">
                <div class="detail-label">结课时间</div>
                <div class="detail-value"><%= course.getEndDate() %></div>
            </div>
        </div>

        <div class="price-section">
            <div>
                <div class="detail-label">原价</div>
                <div class="original-price">¥<%= course.getPrice() %></div>
            </div>
            <div>
                <div class="detail-label">优惠价格</div>
                <div class="discount-price">¥<%= price %></div>
            </div>
        </div>
    </div>

    <%
            }
        }
    %>

    <div class="total-price">
        订单总价: <span>¥<%= buy_tprice %></span>
    </div>

    <form action="confirm_payment" method="post" class="payment-form">
        <% for(Course course : courses) { %>
        <input type="hidden" name="courseIds" value="<%= course.getCourseId() %>">
        <% } %>
        <input type="hidden" name="studentId" value="<%= studentId %>">
        <input type="hidden" name="totalPrice" value="<%= buy_tprice %>">
        <button type="submit" class="payment-btn">确认付款</button>
    </form>

    <% if(request.getAttribute("error") != null){ %>
    <div class="error-message">
        <%= request.getAttribute("error") %>
    </div>
    <% } %>
</div>
</body>
</html>